<%@ page contentType="text/html; charset=utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@include file="../included/commons.jsp"%>
<title>
文档浏览器
</title>

</head>
<%
    String ServerIP = request.getServerName();
    String sPageName = "viewattach.jsp";
	String sHost =  request.getHeader("Host");
	String sRAdd = request.getRequestURI(); 
		   sRAdd = sRAdd.substring(0,sRAdd.length()-sPageName.length());
	String BaseUrl = "Http://" + sHost + sRAdd;
%>
<body onload="soaOpen();window.focus();" onunload="soaClose();">
<script language="javascript">
	var bDocOpen = false;	
	function soaOpen() 
	{ 
		var ptype = '${param.type}';
		var pid = 'Word.Document';
		switch(ptype){
		   case "doc":pid="Word.Document";break;
		   case "xls":pid="Excel.Sheet";break;
		   case "ppt":
		   case "pps":pid="PowerPoint.Show";break;
		   default:
			   alert('此文件格式不支持浏览，窗口将关闭');
		       if(openor)
		    	   openor=null;
               window.close();
			   ;
		   
		}
		try {
		
			formData.SOAOfficeCtrl.WebOpen('attachment/${param.fileName}',1,"${loginuser.localName}",pid);
            formData.SOAOfficeCtrl.SaveDocURL = "";   	
								
		}
		catch (e){
		   
           alert("打开文档失败 \n消息: "+e.message);
		}
	} 
	function soaClose()
	{
		try {
			if (bDocOpen)
				formData.SOAOfficeCtrl.Close();
			return true; 
		} 
		catch (e) 
		{ 
			alert("关闭文档失败!\n错误信息："+e.message); 
			return false; 
		} 
	}
</script>
<SCRIPT language="JavaScript" event="OnDocumentOpened(str, obj)"
	for="SOAOfficeCtrl">
			bDocOpen = true;
		</SCRIPT>
<SCRIPT language="JavaScript" event="OnDocumentClosed()"
	for="SOAOfficeCtrl">
			bDocOpen = false;
		</SCRIPT>
<form name="formData" method="post" id="formData">
<OBJECT id="SOAOfficeCtrl"
	codeBase="${base}jsp/SOAOffice.ocx#version=4,0,1,0" height="100%"
	width="100%" classid="clsid:BBD098CA-63C3-4105-B7AF-5FF3E2649082"
	data="">
<param name="Server" value="<%=ServerIP%>">
<param name="ServerPort" value="4357">
<param name="Toolbars" value="0">
<param name="Menubar" value="0">
<SPAN STYLE="color: red">
未能载入SOAOfficeCtrl文档控件。请在安装控件的提示对话框里确认安装，才能使用本控件的功能。
</SPAN>
</OBJECT>
</form>
</body>
</html>
